package com.njtoyo.taxi.admin.mapper.master.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.njtoyo.taxi.admin.rest.pojo.dto.activity.orderCompletionReward.CustomerDetailSpecification;
import lombok.Data;

import java.util.Date;

@Data
public class CustomerRegionActivityRule {
    private Long id;

    //乘客区域ID
    private Long customerRegionId;

    //0:新乘客注册
    private Integer activityCategory;

    //开始时间
    private Date startedAt;

    //结束时间
    private Date endedAt;

    //0:未开通,1:开通
    private Boolean isOpen;

    //具体配置
    private String detailSpecification;

    //创建时间
    private Date createdAt;

    //更新时间
    private Date updatedAt;

    @TableField(exist = false)
    private CustomerDetailSpecification parsedDetailSpecification;

    public CustomerDetailSpecification parseDetailSpecification() {
        if (this.detailSpecification == null || this.parsedDetailSpecification != null) {
            return this.parsedDetailSpecification;
        }
        CustomerDetailSpecification customerDetailSpecification = JSON.parseObject(this.detailSpecification, CustomerDetailSpecification.class);

        return customerDetailSpecification;
    }
}
